package com.xbongbong.paas.model.impl;

import com.xbongbong.paas.domain.dao.CoverPaasMenuDao;
import com.xbongbong.paas.domain.entity.CoverPaasMenuEntity;
import com.xbongbong.paas.model.CoverPaasMenuModel;
import com.xbongbong.paas.toolbox.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * MenuModel业务实现
 * @author wufeng
 * @time 2018-8-8 10:10
 */
@Service("coverPassMenuModel")
public class CoverPaasMenuModelImpl implements CoverPaasMenuModel {

    @Resource
    private CoverPaasMenuDao coverPaasMenuDao;

    @Override
    public Integer insert(CoverPaasMenuEntity entity) {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return coverPaasMenuDao.insert(entity);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer update(CoverPaasMenuEntity entity) {
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        return coverPaasMenuDao.update(entity);
    }

    @Override
    public List findEntitys(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return null;
    }

    @Override
    public void save(CoverPaasMenuEntity entity){
        if (entity.getId() == null || entity.getId() == 0) {
            insert(entity);
        } else {
            update(entity);
        }
    }

    @Override
    public List<CoverPaasMenuEntity> getList(String corpid) {
        return coverPaasMenuDao.getListByCorpid(corpid);
    }

    @Override
    public Integer updateBatch(List<CoverPaasMenuEntity> list,String corpid) {
        return coverPaasMenuDao.updateBatch(list,corpid);
    }

    @Override
    public Integer insertBatch(List<CoverPaasMenuEntity> list) {
        return coverPaasMenuDao.insertBatch(list);
    }
    @Override
    public Integer deleteByMenuIds(List<Long> menuIds,String corpid){
        return coverPaasMenuDao.deleteByMenuIds(menuIds,corpid);
    }
}
